

package tables

import (
	"fmt"
	"game/game-design/loader"
	"strings"
	ministruct "sanguo/sanguo-design/src/ministruct"
)


var SkillLogicTable *SkillLogicTableStruct = &SkillLogicTableStruct{}

type SkillLogicTableStruct struct {
	loader.DesignTable[SkillLogicCfg]
	
	
	logicIdCollector map[string][]*SkillLogicCfg
	
	
}

func (t *SkillLogicTableStruct) FileName() string {
	return "J技能_技能逻辑"
}


// 从容器索引中获取对象，获取不到会抛异常
func (t *SkillLogicTableStruct) GetInLogicIdCollector(
	logicId int32,
) []*SkillLogicCfg {
	key :=
		fmt.Sprint(logicId)
	
	cfg, ok := t.logicIdCollector[key]
	if !ok {
		panic("SkillLogicTable when GetInLogicIdCollector use key not found " + key)
	}
	return cfg
}

// 从容器索引中查找对象，获取不到会返回null
func (t *SkillLogicTableStruct) FindInLogicIdCollector(
	logicId int32,
) ([]*SkillLogicCfg, bool) {
	key :=
		fmt.Sprint(logicId)
	
	cfg, ok := t.logicIdCollector[key]
	return cfg, ok
}

// 加载logicIdCollector容器索引
func (t *SkillLogicTableStruct) loadLogicIdCollector() {
	logicIdCollector := make(map[string][]*SkillLogicCfg)
	for _, v := range t.All() {
		keys := []string {
			fmt.Sprint(v.logicId),
		}
		key := strings.Join(keys, "_")
		logicIdCollector[key] = append(logicIdCollector[key], v)
	}
	t.logicIdCollector = logicIdCollector
}


func (t *SkillLogicTableStruct) LoadAutoGenerate() {

	//加载容器索引
	t.loadLogicIdCollector()
	
}



type SkillLogicCfg struct {
	logicId int32 //逻辑ID
	step int32 //步骤
	subStep int32 //子步骤
	find string //寻找目标方式
	findParams string //寻找目标参数
	passiveOn int32 //被动作用主动技能
	doThing string //逻辑词条
	doIfParams string //逻辑判断参数
	doParams string //词条参数
	upDoParams string //增强词条参数
	limit string //词条触发限制
}
// 逻辑ID
func (c *SkillLogicCfg) GetLogicId() int32 {
	return c.logicId
}
// 步骤
func (c *SkillLogicCfg) GetStep() int32 {
	return c.step
}
// 子步骤
func (c *SkillLogicCfg) GetSubStep() int32 {
	return c.subStep
}
// 寻找目标方式
func (c *SkillLogicCfg) GetFind() string {
	return c.find
}
// 寻找目标参数
func (c *SkillLogicCfg) GetFindParams() string {
	return c.findParams
}
// 被动作用主动技能
func (c *SkillLogicCfg) GetPassiveOn() int32 {
	return c.passiveOn
}
// 逻辑词条
func (c *SkillLogicCfg) GetDoThing() string {
	return c.doThing
}
// 逻辑判断参数
func (c *SkillLogicCfg) GetDoIfParams() string {
	return c.doIfParams
}
// 词条参数
func (c *SkillLogicCfg) GetDoParams() string {
	return c.doParams
}
// 增强词条参数
func (c *SkillLogicCfg) GetUpDoParams() string {
	return c.upDoParams
}
// 词条触发限制
func (c *SkillLogicCfg) GetLimit() string {
	return c.limit
}

func SkillLogicTableStructNoUse() {
	fmt.Println(ministruct.Cost{})
}
